package com.generalbackend.controller;

import com.generalbackend.common.model.CommonResult;
import com.generalbackend.common.model.entity.CommonConfig;
import com.generalbackend.common.model.query.CommonConfigQuery;
import com.generalbackend.common.service.CommonConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @Description 公共配置表控制层
* @author tim.xie
* @date 2021-11-18 13:31
*/
@RestController
@RequestMapping(value = "/api/commonConfig")
public class CommonConfigController {

    @Autowired
    private CommonConfigService commonConfigService;


    @RequestMapping(value = "/list" ,method = RequestMethod.POST)
    public CommonResult list(@RequestBody CommonConfigQuery commonConfigQuery){
           return  CommonResult.successCommonResult(commonConfigService.list(commonConfigQuery),"查询列表成功");
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public CommonResult add(@RequestBody CommonConfig commonConfig){
        commonConfigService.insert(commonConfig);
        return CommonResult.successCommonResult("新增公共配置表成功");
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public CommonResult update(@RequestBody CommonConfig commonConfig){
        commonConfigService.update(commonConfig);
        return CommonResult.successCommonResult("修改公共配置表成功");
    }

    @RequestMapping(value = "/deleteById",method = RequestMethod.DELETE)
    public CommonResult deleteById(@RequestParam("id")String id){
        commonConfigService.deleteById(id);
        return CommonResult.successCommonResult("删除公共配置表成功");
    }

    @RequestMapping(value = "/getById",method = RequestMethod.GET)
    public CommonResult getById( @RequestParam("id")String id ){
        return CommonResult.successCommonResult(commonConfigService.selectById(id),"查询成功");
    }

}
